package ru.ifmo.thesis.gp;

import ru.ifmo.thesis.quantities.Percent;

public class MyConfigurationOptionsBuilder {

	private Percent takePercentToNewPopulation = new Percent(0.90d);
	private int movingsPerMutation = 1;
	private double mutationPercent = 0.3d;
	private boolean isPopSizeConstant = true;
	private int populationSizeGuaranteed = 0;
	private boolean naturalSelectorBeforeGenOperators = false;
	private boolean allowDoubletteChromosomes = true;
	private int swappingRate = 5;
	private Percent selectFromPrevGen = new Percent(1.0d);
	private int ofPopulation = 500;
	private Percent crossoverRate = new Percent(0.3); 

	public MyConfigurationOptionsBuilder() {
	}

	public MyConfigurationOptionsBuilder setTakePercentToNewPopulation(
			Percent takePercentToNewPopulation) {
		this.takePercentToNewPopulation = takePercentToNewPopulation;
		return this;
	}

	public MyConfigurationOptionsBuilder setMovingsPerMutation(
			int movingsPerMutation) {
		this.movingsPerMutation = movingsPerMutation;
		return this;
	}

	public MyConfigurationOptionsBuilder setMutationPercent(
			double mutationPercent) {
		this.mutationPercent = mutationPercent;
		return this;
	}

	public MyConfigurationOptionsBuilder setPopSizeConstant(
			boolean isPopSizeConstant) {
		this.isPopSizeConstant = isPopSizeConstant;
		return this;
	}

	public MyConfigurationOptionsBuilder setPopulationSizeGuaranteed(
			int populationSizeGuaranteed) {
		this.populationSizeGuaranteed = populationSizeGuaranteed;
		return this;
	}

	public MyConfigurationOptionsBuilder setNaturalSelectorBeforeGenOperators(
			boolean naturalSelectorBeforeGenOperators) {
		this.naturalSelectorBeforeGenOperators = naturalSelectorBeforeGenOperators;
		return this;
	}

	public MyConfigurationOptionsBuilder setAllowDoubletteChromosomes(
			boolean allowDoubletteChromosomes) {
		this.allowDoubletteChromosomes = allowDoubletteChromosomes;
		return this;
	}

	public MyConfigurationOptionsBuilder setSwappingRate(int swappingRate) {
		this.swappingRate = swappingRate;
		return this;
	}

	public MyConfigurationOptionsBuilder setSelectFromPrevGen(
			Percent selectFromPrevGen) {
		this.selectFromPrevGen = selectFromPrevGen;
		return this;
	}
	
	public MyConfigurationOptionsBuilder setOfPopulation(int ofPopulation) {
		this.ofPopulation = ofPopulation;
		return this;
	}
	
	public MyConfigurationOptionsBuilder setCrossoverRate(Percent crossoverRate) {
		this.crossoverRate = crossoverRate;
		return this;
	}

	public MyConfigurationOptions build() {
		return new MyConfigurationOptions(takePercentToNewPopulation,
				movingsPerMutation, mutationPercent, isPopSizeConstant,
				populationSizeGuaranteed, naturalSelectorBeforeGenOperators,
				allowDoubletteChromosomes, swappingRate, selectFromPrevGen, 
				ofPopulation, crossoverRate);
	}

}
